package auleiy.halo.items;

import auleiy.halo.ModMain;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.event.BuildCreativeModeTabContentsEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.RegistryObject;

public class CreativeTabs {

    private static final DeferredRegister<CreativeModeTab> Registry
            = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ModMain.ModId);

    public static final RegistryObject<CreativeModeTab> MainTab
            = Registry.register("main_tab", () -> CreativeModeTab.builder()
            .title(Component.translatable("tab.ba_halos.main_tab"))
            .icon(() -> new ItemStack(Items.AronaHaloItem.get()))
            .build());

    public static void Initialize(IEventBus modEventBus) {
        Registry.register(modEventBus);
        modEventBus.addListener(CreativeTabs::AddCreative);
    }

    private static void AddCreative(BuildCreativeModeTabContentsEvent event) {
        if (event.getTab() == MainTab.get()) {
            event.accept(Items.AronaHaloItem);
            event.accept(Items.PlanaHaloItem);
        }
    }
}
